package ua.vip.easyportfolio.service;

import org.springframework.beans.factory.FactoryBean;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * User: viktorp
 * Date: 21.03.2010
 * Time: 22:29:07
 */
public class EMF implements FactoryBean<EntityManagerFactory>{
    private static final EntityManagerFactory emfInstance =
        Persistence.createEntityManagerFactory("transactions-optional");
    
    @Override
    public EntityManagerFactory getObject() throws Exception {
        return emfInstance;
    }

    @Override
    public Class<? extends EntityManagerFactory> getObjectType() {
        return EntityManagerFactory.class;
    }

    public static EntityManagerFactory get() {
        return emfInstance;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
